package morseme;

import javax.microedition.lcdui.*;

/**
 *
 * @author craxidile
 */
public class UserTypeMenu extends List implements CommandListener{

    private static final String[] USR_TYPE_LIST
            = new String[]{"Blind Receive","Normal Receive"};
    
    private Displayable prevScreen;
    private MorseME midlet;
    
    private Command backCommand;
    private Command chooseCommand;
    
    private Inbox inboxScreen;
    
    public UserTypeMenu(Displayable prevScreen,Inbox inboxScreen,MorseME midlet){
        super("MorseMe",List.IMPLICIT,USR_TYPE_LIST,null);
        
        this.prevScreen = prevScreen;
        this.inboxScreen = inboxScreen;
        this.midlet = midlet;
        
        this.backCommand = new Command("Back",Command.BACK,1);
        this.chooseCommand = new Command("Choose",Command.OK,2);
        
        addCommand(this.backCommand);
        addCommand(this.chooseCommand);
        
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if(c == this.backCommand){
            Display.getDisplay(this.midlet).setCurrent(this.prevScreen);
        }else if(c == this.chooseCommand || c == SELECT_COMMAND){
            Option.USER_TYPE = getSelectedIndex();
            Display.getDisplay(this.midlet).setCurrent(this.inboxScreen);
        }
    }
    
}
